package o;

import android.graphics.Bitmap;
import android.graphics.Color;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public final class eru extends esa {
    private b ʻ = ˏ(0.74f, 0.55f, 1.0f, 1.0f, 0.35f, 1.0f);
    private b ʼ = ˏ(0.74f, 0.55f, 1.0f, 0.3f, 0.0f, 0.4f);
    private b ˊ = ˏ(0.26f, 0.0f, 0.45f, 1.0f, 0.35f, 1.0f);
    private b ˋ = ˏ(0.5f, 0.3f, 0.7f, 1.0f, 0.35f, 1.0f);
    private final List<b> ˎ;
    private b ˏ = ˏ(0.5f, 0.3f, 0.7f, 0.3f, 0.0f, 0.4f);
    private final int ॱ = ˋ();
    private b ᐝ = ˏ(0.26f, 0.0f, 0.45f, 0.3f, 0.0f, 0.4f);

    public static final class b {
        private float[] ˊ;
        private final int ˋ;
        private final int ॱ;

        b(int i, int i2) {
            this.ˋ = i;
            this.ॱ = i2;
        }

        b(int i, int i2, int i3, int i4) {
            this.ˋ = Color.rgb(i, i2, i3);
            this.ॱ = i4;
        }

        public int ˋ() {
            return this.ˋ;
        }

        public float[] ॱ() {
            if (this.ˊ == null) {
                this.ˊ = new float[3];
                Color.colorToHSV(this.ˋ, this.ˊ);
            }
            return Arrays.copyOf(this.ˊ, this.ˊ.length);
        }

        public int ˊ() {
            return this.ॱ;
        }

        public String toString() {
            return getClass().getSimpleName() + " [RGB: #" + Integer.toHexString(ˋ()) + ']' + " [HSL: " + Arrays.toString(ॱ()) + ']' + " [Population: " + this.ॱ + ']';
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null || getClass() != obj.getClass()) {
                return false;
            }
            b bVar = (b) obj;
            if (this.ॱ == bVar.ॱ && this.ˋ == bVar.ˋ) {
                return true;
            }
            return false;
        }

        public int hashCode() {
            return (this.ˋ * 31) + this.ॱ;
        }
    }

    private eru(List<b> list) {
        this.ˎ = list;
        ˏ();
    }

    public static eru ˏ(Bitmap bitmap) {
        return ˏ(bitmap, 16);
    }

    public static eru ˏ(Bitmap bitmap, int i) {
        ˊ(bitmap);
        Bitmap ˎ = ˎ(bitmap);
        err ॱ = err.ॱ(ˎ, i);
        if (ˎ != bitmap) {
            ˎ.recycle();
        }
        return new eru(ॱ.ˎ());
    }

    private static Bitmap ˎ(Bitmap bitmap) {
        int min = Math.min(bitmap.getWidth(), bitmap.getHeight());
        if (min <= 100) {
            return bitmap;
        }
        float f = 100.0f / ((float) min);
        return Bitmap.createScaledBitmap(bitmap, Math.round(((float) bitmap.getWidth()) * f), Math.round(f * ((float) bitmap.getHeight())), false);
    }

    private static float ॱ(float f, float f2, float f3, float f4, int i, int i2) {
        return ˋ(new float[]{ˏ(f, f2), 3.0f, ˏ(f3, f4), 6.0f, ((float) i) / ((float) i2), 1.0f});
    }

    private static float[] ॱ(b bVar) {
        Object obj = new float[3];
        System.arraycopy(bVar.ॱ(), 0, obj, 0, 3);
        return obj;
    }

    private static float ˏ(float f, float f2) {
        return 1.0f - Math.abs(f - f2);
    }

    private static float ˋ(float[] fArr) {
        float f = 0.0f;
        float f2 = 0.0f;
        for (int i = 0; i < fArr.length; i += 2) {
            float f3 = fArr[i];
            float f4 = fArr[i + 1];
            f2 += f3 * f4;
            f += f4;
        }
        return f2 / f;
    }

    private static void ˊ(Bitmap bitmap) {
        if (bitmap == null) {
            throw new IllegalArgumentException("bitmap can not be null");
        } else if (bitmap.isRecycled()) {
            throw new IllegalArgumentException("bitmap can not be recycled");
        }
    }

    public List<b> ˎ() {
        return Collections.unmodifiableList(this.ˎ);
    }

    private boolean ˊ(b bVar) {
        return this.ˋ == bVar || this.ˊ == bVar || this.ʻ == bVar || this.ˏ == bVar || this.ᐝ == bVar || this.ʼ == bVar;
    }

    private b ˏ(float f, float f2, float f3, float f4, float f5, float f6) {
        b bVar = null;
        float f7 = 0.0f;
        for (b bVar2 : this.ˎ) {
            b bVar22;
            float f8 = bVar22.ॱ()[1];
            float f9 = bVar22.ॱ()[2];
            if (f8 >= f5 && f8 <= f6 && f9 >= f2 && f9 <= f3 && !ˊ(bVar22)) {
                f8 = ॱ(f8, f4, f9, f, bVar22.ˊ(), this.ॱ);
                if (bVar != null && f8 <= f7) {
                    f8 = f7;
                    bVar22 = bVar;
                }
                f7 = f8;
                bVar = bVar22;
            }
        }
        return bVar;
    }

    private void ˏ() {
        if (this.ˋ == null && this.ˊ != null) {
            float[] ॱ = ॱ(this.ˊ);
            ॱ[2] = 0.5f;
            this.ˋ = new b(Color.HSVToColor(ॱ), 0);
        }
        if (this.ˊ == null && this.ˋ != null) {
            ॱ = ॱ(this.ˋ);
            ॱ[2] = 0.26f;
            this.ˊ = new b(Color.HSVToColor(ॱ), 0);
        }
    }

    private int ˋ() {
        int i = 0;
        for (b ˊ : this.ˎ) {
            i = Math.max(i, ˊ.ˊ());
        }
        return i;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        eru o_eru = (eru) obj;
        if (ˋ(o_eru)) {
            return false;
        }
        if (this.ˋ != null) {
            return this.ˋ.equals(o_eru.ˋ);
        }
        if (o_eru.ˋ != null) {
            return false;
        }
        return true;
    }

    private boolean ˋ(eru o_eru) {
        if (this.ˎ != null) {
            if (!this.ˎ.equals(o_eru.ˎ)) {
                return true;
            }
        } else if (o_eru.ˎ != null) {
            return true;
        }
        if (this.ᐝ != null) {
            if (!this.ᐝ.equals(o_eru.ᐝ)) {
                return true;
            }
        } else if (o_eru.ᐝ != null) {
            return true;
        }
        if (this.ˊ != null) {
            if (!this.ˊ.equals(o_eru.ˊ)) {
                return true;
            }
        } else if (o_eru.ˊ != null) {
            return true;
        }
        if (this.ʼ != null) {
            if (!this.ʼ.equals(o_eru.ʼ)) {
                return true;
            }
        } else if (o_eru.ʼ != null) {
            return true;
        }
        if (this.ʻ != null) {
            if (!this.ʻ.equals(o_eru.ʻ)) {
                return true;
            }
        } else if (o_eru.ʻ != null) {
            return true;
        }
        if (this.ˏ != null) {
            if (!this.ˏ.equals(o_eru.ˏ)) {
                return true;
            }
        } else if (o_eru.ˏ != null) {
            return true;
        }
        return false;
    }

    public int hashCode() {
        int hashCode;
        int i = 0;
        int hashCode2 = (this.ˎ != null ? this.ˎ.hashCode() : 0) * 31;
        if (this.ˋ != null) {
            hashCode = this.ˋ.hashCode();
        } else {
            hashCode = 0;
        }
        hashCode2 = (hashCode + hashCode2) * 31;
        if (this.ˏ != null) {
            hashCode = this.ˏ.hashCode();
        } else {
            hashCode = 0;
        }
        hashCode2 = (hashCode + hashCode2) * 31;
        if (this.ˊ != null) {
            hashCode = this.ˊ.hashCode();
        } else {
            hashCode = 0;
        }
        hashCode2 = (hashCode + hashCode2) * 31;
        if (this.ᐝ != null) {
            hashCode = this.ᐝ.hashCode();
        } else {
            hashCode = 0;
        }
        hashCode2 = (hashCode + hashCode2) * 31;
        if (this.ʻ != null) {
            hashCode = this.ʻ.hashCode();
        } else {
            hashCode = 0;
        }
        hashCode = (hashCode + hashCode2) * 31;
        if (this.ʼ != null) {
            i = this.ʼ.hashCode();
        }
        return hashCode + i;
    }
}
